***These commands import the predicted probabilities from excel and generate the necessary variables for presentation of the results***
***Please begin with the commands below the dashed line in case you want to rerun the analysis only

*commands for preparation of data in STATA format
import excel "F:\WSCEP\Governance Paper with PB data\differences pred_prob.xlsx", sheet("Ark1") firstrow
sum
br

*use this if using a computer in German or Scandinavian countries=>comma is dot and vice versa, check this carefully before
destring pred_prob SE Z converseprobability lb ub, replace dpcomma

*if not use this
destring pred_prob SE Z converseprobability lb ub, replace
br
sum


lab def pro 0 "Pensions" 1 "Unemployment benefits"
lab val programme pro 

lab def eve 0 "No event" 1 "Single event"
lab val single_event

lab def dr 0 "Defector" 1 "Rewarder"
lab val def_rew dr 

lab def dir 0 "Expansion" 1 "Cut"
lab val direction dir

lab def sig 0 "no sig. diff." 1 "Sig. diff."
lab val significance sig

gen diff_pp=converseprobability-pred_prob

gen neg_diff_pp=pred_prob-converseprobability

*---------------------------------------------------------------------------------------------------------------------------------------
****************************************************************************************************************************************
*all following commands create Figure 6 based on the predicted probabilities derived from the special events models*
****************************************************************************************************************************************

use "F:\WSCEP\Governance Paper with PB data\differences special events.dta"


**********************Pensions********************

*difference event-no event for pensions, expansions
twoway line neg_diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==0, lcolor(cranberry) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==0&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick) /// 
|| line neg_diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==0, lcolor(blue) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==0&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
ylabel(.2 "20" .15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_exp_negsig", replace)


*difference event-no event for pensions, expansions; BW and 3 events on x-axis
twoway line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==0&single==0&dir==0, lcolor(black) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==0&single==0&dir==0&sig==1, lcolor(black) lpattern(solid) lwidth(thick) /// 
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==1&single==0&dir==0, lcolor(gs8) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==1&single==0&dir==0&sig==1, lcolor(gs8) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before    ", size(medium) color(black) height(5)) ///
ylabel(.15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_exp_negsig_bw", replace)


*difference event-no event for pensions, cutbacks
twoway line neg_diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==1, lcolor(cranberry) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==1&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick) /// 
|| line neg_diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==1, lcolor(blue) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==1&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7", angle(0)) ///
ylabel(.2 "20" .15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Cutbacks", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_cut_negsig", replace)



*difference event-no event for pensions, cutbacks; BW and 3 events on x-axis
twoway line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==0&single==0&dir==1, lcolor(black) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==0&single==0&dir==1&sig==1, lcolor(black) lpattern(solid) lwidth(thick) /// 
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==1&single==0&dir==1, lcolor(gs8) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==0&def_rew==1&single==0&dir==1&sig==1, lcolor(gs8) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before   ", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3", angle(0)) ///
ylabel(.15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Cutbacks", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_cut_negsig_bw", replace)

grc1leg event_pens_exp_negsig event_pens_cut_negsig, graphregion(color(white)) ycommon


*for combined graph Figure 6
grc1leg event_pens_exp_negsig_bw event_pens_cut_negsig_bw, graphregion(color(white)) ycommon ///
title("Pensions", size(medium) color(black)) name("event_pens_bw", replace) 


*************************unemployment benefits************************


*difference event-no event for unemployment benefits, expansions
twoway line neg_diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==0, lcolor(cranberry) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==0&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick)  ///
|| line neg_diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==0, lcolor(blue) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==0&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8", angle(0)) ///
ylabel(.2 "20" .15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_exp_negsig", replace)


*difference event-no event for unemployment benefits, expansions; BW and 3 events on x-axis
twoway line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==0&single==0&dir==0, lcolor(black) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==0&single==0&dir==0&sig==1, lcolor(black) lpattern(solid) lwidth(thick)  ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==1&single==0&dir==0, lcolor(gs8) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==1&single==0&dir==0&sig==1, lcolor(gs8) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3", angle(0)) ///
ylabel(.15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_exp_negsig_bw", replace)


*difference event-no event for unemployment benefits, cutbacks
twoway line neg_diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==1, lcolor(cranberry) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==1&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick)  ///
|| line neg_diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==1, lcolor(blue) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==1&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" 14 "14" 15 "15", angle(0)) ///
ylabel(.2 "20" .15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Cutbacks", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_cut_negsig", replace)


*difference event-no event for unemployment benefits, cutbacks; BW and 3 events on x-axis
twoway line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==0&single==0&dir==1, lcolor(black) lpattern(longdash_dot)  ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==0&single==0&dir==1&sig==1, lcolor(black) lpattern(solid) lwidth(thick)  ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==1&single==0&dir==1, lcolor(gs8) lpattern(dash) ///
|| line neg_diff_pp nr_reforms if nr_reforms<4&programme==1&def_rew==1&single==0&dir==1&sig==1, lcolor(gs8) lpattern(solid) lwidth(thick) ///
ytitle("Difference no event-event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before     ", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3", angle(0)) ///
ylabel(.15 "15" .1 "10" .05 "5" .0 "0" -.05 "-5" -.10 "-10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Cutbacks", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_cut_negsig_bw", replace)

grc1leg event_ub_exp_negsig event_ub_cut_negsig, graphregion(color(white)) ycommon
grc1leg event_ub_exp_negsig_bw event_ub_cut_negsig_bw, graphregion(color(white)) ycommon

*for combined graph Figure 6, with 3 events on x-axis
grc1leg event_ub_exp_negsig_bw event_ub_cut_negsig_bw, graphregion(color(white)) ycommon ///
title("Unemployment insurance", size(medium) color(black)) name("event_ub_bw", replace) 

grc1leg event_pens_bw event_ub_bw, graphregion(color(white)) ycommon cols(1)
graph display, xsize(5.5) ysize(6.5)


***These commands create and save Figure 6 based on the black-white version of the graphs above
graph save Graph "F:\WSCEP\Governance Paper with PB data\Figure 6 special event.gph", replace
graph save Graph "F:\WSCEP\Governance Paper with PB data\Final Version Governance\Figure 6.gph", replace
graph export "F:\WSCEP\Governance Paper with PB data\Final Version Governance\Figure 6.tif", replace width(1200)



***different versions and presentations of the graphs (not appearing in article, used for conference presentations)***




*difference event-no event for pensions, expansions
twoway line diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==0, lcolor(cranberry) lpattern(solid)  ///
|| line diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==0, lcolor(blue) lpattern(solid) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
ylabel(-.02 "-2" -.01 "-1" .0 "0" .01 "1" .02 "2", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 2 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_exp", replace)


*difference event-no event for pensions, cutbacks
twoway line diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==1, lcolor(cranberry) lpattern(solid)  ///
|| line diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==1, lcolor(blue) lpattern(solid) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7", angle(0)) ///
ylabel(-.2 "-20" -.15 "-15" -.1 "-10" -.05 "5" .0 "0" .05 "5", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 2 "Rewarders")) ///
title("Cuts", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_cut", replace)

grc1leg event_pens_exp event_pens_cut, graphregion(color(white)) title("Difference in predicted probabilities for occurence of single event minus no event", size(medium) color(black))



*difference event-no event for unemployment benefits, expansions
twoway line diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==0, lcolor(cranberry) lpattern(solid)  ///
|| line diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==0, lcolor(blue) lpattern(solid) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8", angle(0)) ///
ylabel(-.06 "-6" -0.04 "-4" -0.02 "-2" .0 "0" .02 "2" .04 "4" .06 "6" .08 "8" .1 "10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 2 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_exp", replace)


*difference event-no event for unemployment benefits, cutbacks
twoway line diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==1, lcolor(cranberry) lpattern(solid)  ///
|| line diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==1, lcolor(blue) lpattern(solid) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" 14 "14" 15 "15", angle(0)) ///
ylabel(-.2 "-20" -.15 "-15" -.1 "-10" -.05 "5" .0 "0", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 2 "Rewarders")) ///
title("Cuts", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_cut", replace)

grc1leg event_ub_exp event_ub_cut, graphregion(color(white)) title("Difference in predicted probabilities for occurence of single event minus no event", size(medium) color(black))


******************************with significance********************

*difference event-no event for pensions, expansions
twoway line diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==0, lcolor(cranberry) lpattern(dash)  ///
|| line diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==0&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick) /// 
|| line diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==0, lcolor(blue) lpattern(dash) ///
|| line diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==0&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
ylabel(-.2 "-20" -.15 "-15" -.1 "-10" -.05 "5" .0 "0" .05 "5" .10 "10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_exp_sig", replace)


*difference event-no event for pensions, cutbacks
twoway line diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==1, lcolor(cranberry) lpattern(dash)  ///
|| line diff_pp nr_reforms if programme==0&def_rew==0&single==0&dir==1&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick) /// 
|| line diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==1, lcolor(blue) lpattern(dash) ///
|| line diff_pp nr_reforms if programme==0&def_rew==1&single==0&dir==1&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7", angle(0)) ///
ylabel(-.2 "-20" -.15 "-15" -.1 "-10" -.05 "5" .0 "0" .05 "5" .10 "10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Cuts", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_pens_cut_sig", replace)


grc1leg event_pens_exp_sig event_pens_cut_sig, graphregion(color(white)) ycommon title("Difference in predicted probabilities for occurence of single event minus no event", size(medium) color(black))




*difference event-no event for unemployment benefits, expansions
twoway line diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==0, lcolor(cranberry) lpattern(dash)  ///
|| line diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==0&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick)  ///
|| line diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==0, lcolor(blue) lpattern(dash) ///
|| line diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==0&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of expansions in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8", angle(0)) ///
ylabel(-.2 "-20" -.15 "-15" -.1 "-10" -.05 "5" .0 "0" .05 "5" .10 "10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Expansions", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_exp_sig", replace)


*difference event-no event for unemployment benefits, cutbacks
twoway line diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==1, lcolor(cranberry) lpattern(dash)  ///
|| line diff_pp nr_reforms if programme==1&def_rew==0&single==0&dir==1&sig==1, lcolor(cranberry) lpattern(solid) lwidth(thick)  ///
|| line diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==1, lcolor(blue) lpattern(dash) ///
|| line diff_pp nr_reforms if programme==1&def_rew==1&single==0&dir==1&sig==1, lcolor(blue) lpattern(solid) lwidth(thick) ///
ytitle("Difference event-no event, %", axis(1) size(medium) height(5)) ///
xtitle("Number of cutbacks in month before", size(medium) color(black) height(5)) ///
xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" 14 "14" 15 "15", angle(0)) ///
ylabel(-.2 "-20" -.15 "-15" -.1 "-10" -.05 "5" .0 "0" .05 "5" .10 "10", angle (0) labsize(medium)) ///
legend(order(1 "Defectors" 3 "Rewarders")) ///
title("Cuts", size(medium) color(black) height(5)) ///
graphregion(color(white)) bgcolor(white) recast(line) ///
name("event_ub_cut_sig", replace)

grc1leg event_ub_exp_sig event_ub_cut_sig, graphregion(color(white)) ycommon title("Difference in predicted probabilities for occurence of single event minus no event", size(medium) color(black))











